# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2023-02-04
desc: 
sample: 
"""
import os

from locust import HttpUser, task, TaskSet, SequentialTaskSet


class UserBehavior(SequentialTaskSet):
    @task(3)
    def index(self):
        print("index")

    @task(1)
    def profile(self):
        print("profile")

#混合场景
class Login(HttpUser):
    host = 'http://82.156.74.26:9088/pinter'
    tasks=[UserBehavior]

    # @task(1)  # locust
    # def login1(self):
    #     print('---login1')
    #     url = self.host + '/com/login1'
    #     data = {"userName": 'admin', 'password': '1234'}
    #     with self.client.post(url=url, data=data, catch_response=True, timeout=5) as response:
    #         #if response.json()['message'] == 'success':
    #         if response.json().get('message') == 'success':
    #             response.success()
    #         else:
    #             response.failure(response.json())
    #
    # @task(1)  # locust
    # def login2(self):
    #     print('---login2')
    #     url = self.host + '/com/login2'
    #     data = {"userName": 'admin', 'password': '1234'}
    #     with self.client.post(url=url, data=data, catch_response=True, timeout=5) as response:
    #         #if response.json()['message'] == 'success':
    #         if response.json().get('message') == 'success':
    #             response.success()
    #         else:
    #             response.failure(response.json())


if __name__ == '__main__':
    os.system('locust -f Login混合顺序.py')
